import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yqmssa_app/config/app_config.dart';
import 'package:yqmssa_app/router/page_router.dart';
import 'package:yqmssa_app/utils/shared_utils.dart';

class XieYiWidget extends StatelessWidget {
  const XieYiWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          width: double.maxFinite,
          margin: const EdgeInsets.symmetric(horizontal: 20),
          padding: const EdgeInsets.symmetric(horizontal: 16),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(10),
            border: Border.all(color: const Color(0XFFEBEDF0), width: 1),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              const SizedBox(height: 26),
              const Text(
                "隐私保护提示",
                style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0XFF323233)),
              ),
              const SizedBox(height: 25),
              Center(
                child: Align(
                  alignment: Alignment.centerLeft,
                  child: RichText(
                    text: TextSpan(style: const TextStyle(color: Color(0XFF666666), fontSize: 13, height: 1.6), children: [
                      const TextSpan(text: "感谢您信任并使用!我们非常重视您的个人信息和隐私保护为了更好地保障您的个人权益。在您使用我们的产品前,请务必审慎阅读"),
                      WidgetSpan(
                        child: InkWell(
                          onTap: () {
                            Get.toNamed(PageRouter.agreement, parameters: {"title": "用户注册协议", "url": AppConfig.xieYIData.userAgreementUrl});
                          },
                          child: const Text(
                            '《用户注册协议》',
                            style: TextStyle(
                              color: Color(0XFFFF6800),
                              fontSize: 13,
                              decoration: TextDecoration.underline,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                        ),
                      ),
                      const TextSpan(
                        text: '与',
                        style: TextStyle(
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      WidgetSpan(
                          child: InkWell(
                              onTap: () {
                                Get.toNamed(PageRouter.agreement, parameters: {"title": "隐私政策", "url": AppConfig.xieYIData.privacyAgreementUrl});
                              },
                              child: const Text(
                                '《隐私政策》',
                                style: TextStyle(
                                  color: Color(0XFFFF6800),
                                  fontSize: 13,
                                  decoration: TextDecoration.underline,
                                  fontWeight: FontWeight.bold,
                                ),
                              ))),
                      const TextSpan(
                        text: "内的所有条款，了解我们申请相关权限及收集使用您信息的情况，以及对个人信息的保护措施。"
                            "关于隐私政策保护，特向您说明如下:"
                            "1.为向您提供服务并保护您的信息安全，基于您的明示授权，我们需在必要范围内收集、使用、共享并保存您的个人信息。"
                            "2.我们会采用业界安全措施标准保护您的信息安全，未经您的授权同意，我们不会向任何第三方共享您的信息或用于您未授权的其他用途。"
                            "3.为保障APP稳定运行或提供服务，您可能需要根据不同业务场景开启必要的权限。若您未开启相应权限，则APP不会收集相应的信息。",
                      ),
                    ]),
                  ),
                ),
              ),
              const SizedBox(height: 20),
              RichText(
                text: TextSpan(
                    style: const TextStyle(
                      color: Color(0XFF666666),
                      fontSize: 13,
                    ),
                    children: [
                      const TextSpan(
                        text: "您可以阅读完整的",
                        style: TextStyle(
                          color: Color(0XFF999999),
                          fontSize: 13,
                        ),
                      ),
                      WidgetSpan(
                          child: InkWell(
                        onTap: () {
                          Get.toNamed(PageRouter.agreement, parameters: {"title": "用户注册协议", "url": AppConfig.xieYIData.userAgreementUrl});
                        },
                        child: const Text("《用户注册协议》",
                            style: TextStyle(
                              color: Color(0XFFFF6800),
                              fontSize: 13,
                              fontWeight: FontWeight.bold,
                            )),
                      )),
                      const TextSpan(
                        text: "和",
                        style: TextStyle(
                          color: Color(0XFF999999),
                          fontSize: 13,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      WidgetSpan(
                          child: InkWell(
                        onTap: () {
                          Get.toNamed(PageRouter.agreement, parameters: {"title": "隐私政策", "url": AppConfig.xieYIData.privacyAgreementUrl});
                        },
                        child: const Text("《隐私政策》",
                            style: TextStyle(
                              color: Color(0XFFFF6800),
                              fontSize: 13,
                              fontWeight: FontWeight.bold,
                            )),
                      )),
                    ]),
              ),
              const SizedBox(height: 20),
              Row(
                children: [
                  Expanded(
                    child: GestureDetector(
                      behavior: HitTestBehavior.translucent,
                      onTap: () {
                        Get.back(result: false);
                      },
                      child: Container(
                        height: 48,
                        alignment: Alignment.center,
                        child: const Text(
                          "暂不同意",
                          textAlign: TextAlign.center,
                          style: TextStyle(fontSize: 16, color: Color(0XFF999999)),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: GestureDetector(
                      behavior: HitTestBehavior.translucent,
                      onTap: () {
                        sharedUtils.agreement = true;
                        Get.back(result: true);
                      },
                      child: Container(
                        height: 48,
                        alignment: Alignment.center,
                        child: const Text(
                          "同意并继续",
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            fontSize: 16,
                            color: Color(0XFFFF6800),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
